#include "head.h"

bool register_user(int net_fd, MYSQL* conn){


    char user_name[32] = {0};
    char password[32] = {0};

    int user_name_len;//用户名长度                                     ^L
    int recv_byte = recv(net_fd, &user_name_len, sizeof(int), 0);

    recv(net_fd, user_name, user_name_len, 0);
    recv(net_fd, password, sizeof(password), 0);


    bool register_login = false;

    register_login = utils_register(conn, user_name, password);

    if(register_login){
        int s = 1;
        send(net_fd, &s, sizeof(int), MSG_NOSIGNAL);
    }else{
        int s = 0;
        send(net_fd, &s, sizeof(int), MSG_NOSIGNAL);
        return false;
    }

    return true;

/*
    printf("User name: %s  password: %s\n", user_name, password);

    int mkdir_result = mkdir(user_name, 0777);
    if(mkdir_result == -1){
        int err = 0;
        send(net_fd, &err, sizeof(int), MSG_NOSIGNAL);
        printf("注册失败\n");
    }

    int s = 1;
    send(net_fd, &s, sizeof(int), MSG_NOSIGNAL);

    return true;
*/
}

